package com.styytech.dadabao.ui.my;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.lidroid.xutils.view.annotation.ContentView;
import com.styytech.dadabao.R;
import com.styytech.dadabao.base.BaseActivity;
import com.styytech.dadabao.constant.ConstantsCommon;
import com.styytech.dadabao.constant.ConstantsServerUrl;
import com.styytech.dadabao.ui.project.MoreDetailRecordFragment;

/**
 * Created by User on 2015/8/27.
 */
@ContentView(R.layout.activity_user_record)
public class UserRecordActivity extends BaseActivity {
    /**
     * 用于对Fragment进行管理
     */
    private MoreDetailRecordFragment fragment;
    private FragmentManager fragmentManager;
    private FragmentTransaction transaction;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initViews();
    }
    private void initViews(){
        setTopBar("投资记录", View.VISIBLE,View.VISIBLE,"返回");

        fragmentManager = getSupportFragmentManager();
        transaction = fragmentManager.beginTransaction();
        if (fragment == null) {
            // 如果MessageFragment为空，则创建一个并添加到界面上
            String newsUrl = ConstantsServerUrl.getUserInvestmentRecordList();
            fragment = MoreDetailRecordFragment.newInstance(newsUrl,ConstantsCommon.DATA_SRC_USER_RECORD,
                    ConstantsCommon.DATA_SRC_RECORD, "",0);
            transaction.add(R.id.fl_content, fragment, "ID_RECORD");
        } else {
            // 如果MessageFragment不为空，则直接将它显示出来
            transaction.show(fragment);
        }
        transaction.commit();
    }
}
